package com.tryine.soudafu.healty.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tryine.common.resp.BaseResp;
import com.tryine.soudafu.healty.api.BannerProvider;
import com.tryine.soudafu.healty.vo.req.banner.BannerInfoReq;
import com.tryine.soudafu.healty.vo.resp.banner.BannerInfoResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ludans
 * @program soudafu-healty-controller
 * @date 2020/7/16 10:05
 */
@RestController
@RequestMapping(value = "/banner")
@Api(description = "轮播图相关API")
public class BannerController {

    @Reference
    private BannerProvider bannerProvider;

    @ApiOperation(value = "轮播图", notes = "Banner位置 首页 传 0 ， 健康 传 1 。   \n" +
            "platform 表示平台。   \n" +
            "type 现在统一传 0，也可以不传")
    @RequestMapping(value = "listBanner", method = RequestMethod.POST)
    public BaseResp<List<BannerInfoResp>> listBanner(@RequestBody BannerInfoReq req) {
        Assert.notNull(req.getBannerLocation(), "BannerLocation不能为空！");
        Assert.notNull(req.getPlatform(), "Platform不能为空！");
        BaseResp<List<BannerInfoResp>> listBaseResp = bannerProvider.listBanner(req);
        return listBaseResp;
    }
}
